package com.sskj.phoenixcoin.presenter;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.MD5Util;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.bean.UserData;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.phoenixcoin.MainActivity;
import com.sskj.phoenixcoin.bean.AppBanlance;
import com.sskj.phoenixcoin.bean.UpdataBean;
import com.sskj.phoenixcoin.http.HttpConfig;

public class MainPresenter extends BasePresenter<MainActivity> {
    // 获取用户资产
    public void getBanlance(String id) {
        OkGo.<HttpData<AppBanlance>>post(HttpConfig.BASE_URL + HttpConfig.BANLANCE)
                .params("systemType", "ANDROID")
                .params("id", id)
                .tag(this)
                .execute(new JsonCallBack<HttpData<AppBanlance>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<AppBanlance>> response) {
                        HttpData body = response.body();
                        if (body.getStatus() == HttpConfig.OK) {
                            mView.loginSuccess((AppBanlance) body.getData());
                        }
                    }
                });
    }


    public void updata(String verName) {
        OkGo.<HttpData<UpdataBean>>post(HttpConfig.BASE_URL + "/phoenix/app/appVersion/selectNewAppVersion")
                .params("appType", 2)
                .execute(new JsonCallBack<HttpData<UpdataBean>>() {
                    @Override
                    public void onSuccess(Response<HttpData<UpdataBean>> response) {
                        HttpData<UpdataBean> body = response.body();
                        if (body.getStatus() == HttpConfig.OK) {
                            mView.needUpdata(body.getData());
                        }
                    }
                });

    }
}
